{extend name="../../../view/public/base" /}

{block name="css"}
<style>
    body {
        background-color: #F2F2F2;
    }
</style>
{/block}

{block name="body"}
<div style="padding: 20px; background-color: #F2F2F2;">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <form class="layui-form" lay-filter="addForm" autocomplete="off">
                    <!--后面对应 应该微信绑定对应的user表id-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">后面对应 应该微信绑定对应的user表id</label>
                        <div class="layui-input-block">
                            <input type="number" name="uid" placeholder="请输入后面对应 应该微信绑定对应的user表id" class="layui-input" value="{$row.uid}">
                        </div>
                    </div>
                    <!--客户端ID-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">客户端ID</label>
                        <div class="layui-input-block">
                            <input type="text" name="service_id" placeholder="请输入客户端ID" class="layui-input" value="{$row.service_id}">
                        </div>
                    </div>
                    <!--订单ID-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">订单ID</label>
                        <div class="layui-input-block">
                            <input type="number" name="miniapp_order_id" placeholder="请输入订单ID" class="layui-input" value="{$row.miniapp_order_id}">
                        </div>
                    </div>
                    <!--创建人/购买人-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">创建人/购买人</label>
                        <div class="layui-input-block">
                            <input type="number" name="member_id" placeholder="请输入创建人/购买人" class="layui-input" value="{$row.member_id}">
                        </div>
                    </div>
                    <!--应用id-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">应用id</label>
                        <div class="layui-input-block">
                            <input type="number" name="miniapp_id" placeholder="请输入应用id" class="layui-input" value="{$row.miniapp_id}">
                        </div>
                    </div>
                    <!--应用名称-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">应用名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="appname" placeholder="请输入应用名称" class="layui-input" value="{$row.appname}">
                        </div>
                    </div>
                    <!--Logo-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">Logo</label>
                        <div class="layui-input-block">
                            <input type="text" name="head_img" placeholder="请输入Logo" class="layui-input" value="{$row.head_img}">
                        </div>
                    </div>
                    <!--演示二维码-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">演示二维码</label>
                        <div class="layui-input-block">
                            <input type="text" name="qrcode_url" placeholder="请输入演示二维码" class="layui-input" value="{$row.qrcode_url}">
                        </div>
                    </div>
                    <!--小程序appid-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">小程序appid</label>
                        <div class="layui-input-block">
                            <input type="text" name="miniapp_appid" placeholder="请输入小程序appid" class="layui-input" value="{$row.miniapp_appid}">
                        </div>
                    </div>
                    <!--小程序secret-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">小程序secret</label>
                        <div class="layui-input-block">
                            <input type="text" name="miniapp_secret" placeholder="请输入小程序secret" class="layui-input" value="{$row.miniapp_secret}">
                        </div>
                    </div>
                    <!--小程序logo-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">小程序logo</label>
                        <div class="layui-input-block">
                            <input type="text" name="miniapp_head_img" placeholder="请输入小程序logo" class="layui-input" value="{$row.miniapp_head_img}">
                        </div>
                    </div>
                    <!--小程序演示二维码-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">小程序演示二维码</label>
                        <div class="layui-input-block">
                            <input type="text" name="miniapp_qrcode_url" placeholder="请输入小程序演示二维码" class="layui-input" value="{$row.miniapp_qrcode_url}">
                        </div>
                    </div>
                    <!--导航栏颜色-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">导航栏颜色</label>
                        <div class="layui-input-block">
                            <input type="text" name="navbar_color" placeholder="请输入导航栏颜色" class="layui-input" value="{$row.navbar_color}">
                        </div>
                    </div>
                    <!--导航栏样式-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">导航栏样式</label>
                        <div class="layui-input-block">
                            <input type="text" name="navbar_style" placeholder="请输入导航栏样式" class="layui-input" value="{$row.navbar_style}">
                        </div>
                    </div>
                    <!--服务时间-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">服务时间</label>
                        <div class="layui-input-inline">
                            <input id='service_time'  type='text' name='service_time' placeholder='请输入服务时间' class='layui-input'>
                            <!--格式化时间-->
                            <script>
                                formatDate("{$row.service_time}", 'service_time')
                            </script>                            
                        </div>
                    </div>
                    <!--公众号appid-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">公众号appid</label>
                        <div class="layui-input-block">
                            <input type="text" name="mp_appid" placeholder="请输入公众号appid" class="layui-input" value="{$row.mp_appid}">
                        </div>
                    </div>
                    <!--公众号secret-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">公众号secret</label>
                        <div class="layui-input-block">
                            <input type="text" name="mp_secret" placeholder="请输入公众号secret" class="layui-input" value="{$row.mp_secret}">
                        </div>
                    </div>
                    <!--公众号logo-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">公众号logo</label>
                        <div class="layui-input-block">
                            <input type="text" name="mp_head_img" placeholder="请输入公众号logo" class="layui-input" value="{$row.mp_head_img}">
                        </div>
                    </div>
                    <!--公众号演示二维码-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">公众号演示二维码</label>
                        <div class="layui-input-block">
                            <input type="text" name="mp_qrcode_url" placeholder="请输入公众号演示二维码" class="layui-input" value="{$row.mp_qrcode_url}">
                        </div>
                    </div>
                    <!--公众号token-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">公众号token</label>
                        <div class="layui-input-block">
                            <input type="text" name="mp_token" placeholder="请输入公众号token" class="layui-input" value="{$row.mp_token}">
                        </div>
                    </div>
                    <!--公众号AesKey-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">公众号AesKey</label>
                        <div class="layui-input-block">
                            <input type="text" name="mp_aes_key" placeholder="请输入公众号AesKey" class="layui-input" value="{$row.mp_aes_key}">
                        </div>
                    </div>
                    <!--微信服务商:0=独立应用,1=微信服务商-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">微信服务商</label>
                        <div class="layui-input-inline" id="is_psp">
                            <select name="is_psp" lay-verify="required">
                                <option value="" >请选择微信服务商</option>
                                    <option value="0" {eq name="$row.is_psp" value="0"}selected{/eq}>独立应用</option>
                                    <option value="1" {eq name="$row.is_psp" value="1"}selected{/eq}>微信服务商</option>
                            </select>
                        </div>
                    </div>
                    <!--服务商appid-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">服务商appid</label>
                        <div class="layui-input-block">
                            <input type="text" name="psp_appid" placeholder="请输入服务商appid" class="layui-input" value="{$row.psp_appid}">
                        </div>
                    </div>
                    <!--接入方式:0=独立应用,1=开放平台-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">接入方式</label>
                        <div class="layui-input-inline" id="is_open">
                            <select name="is_open" lay-verify="required">
                                <option value="" >请选择接入方式</option>
                                    <option value="0" {eq name="$row.is_open" value="0"}selected{/eq}>独立应用</option>
                                    <option value="1" {eq name="$row.is_open" value="1"}selected{/eq}>开放平台</option>
                            </select>
                        </div>
                    </div>
                    <!--状态:0=正常,1锁定-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">状态</label>
                        <div class="layui-input-inline" id="is_lock">
                            <select name="is_lock" lay-verify="required">
                                <option value="" >请选择状态</option>
                                    <option value="0" {eq name="$row.is_lock" value="0"}selected{/eq}>正常</option>
                            </select>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="submitBtn">立即提交</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

{/block}

{block name="js"}
<script>
    var layer, form, bwajax, upload, $, laydate;

    layui.use(['layer', 'form', 'bwajax', 'upload', 'laydate'], function () {
        layer = layui.layer;
        form = layui.form;
        bwajax = layui.bwajax.instance();
        upload = layui.upload;
        $ = layui.jquery;
        laydate = layui.laydate;

        //服务时间 日期时间选择器
        laydate.render({
            elem: '#service_time'
            ,type: 'datetime'
        });


        //监听提交按钮
        form.on('submit(submitBtn)', function (obj) {
            data = obj.field;

            if(!data.uid) {layer.msg('后面对应 应该微信绑定对应的user表id不能为空', {icon: 2});return false}
            //时间转为时间戳
            data.service_time = Date.parse(data.service_time) / 1000;


            //ajax调用后台接口
            bwajax.post("{:Url('edit')}?id={$row.id}", data)
                .then(function (response) {
                    if (response.data.data.errcode === 0) {
                        layer.msg('提交成功', {icon: 1});
                        submitSuccess();
                    } else {
                        layer.msg(response.data.msg, {icon: 2});
                    }
                })

            return false;
        })
    });
</script>
{/block}